package com.example.bookcar.controller.system;

import com.example.bookcar.common.JsonResult;
import com.example.bookcar.common.Result;
import com.example.bookcar.dto.SearchDTO;
import com.example.bookcar.service.CarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author konglz
 * @Data 2023/3/1 16:48
 */
@Api(value = "车辆控制器")
@RestController
public class CarController {
    @Autowired
    CarService carService;

    @ApiOperation(value = "查询所有车辆信息")
    @GetMapping("/find/list")
    public Result listAll(){
        return new Result(true, "查询所有车辆信息", carService.listAll());
    }

    @ApiOperation(value = "分页查询车辆信息")
    @GetMapping("/find/list/page")
    public Result listPage(@RequestParam("currentPage")Integer currentPage, @RequestParam("pageSize")Integer pageSize){
        return new Result(true, "分页查询车辆信息", carService.listPage(currentPage, pageSize));
    }

    @ApiOperation("分页搜索查询")
    @GetMapping("/list")
    public Result listSearch(@RequestBody SearchDTO searchDTO){
        return new Result(true, "分页搜索查询", carService.listSearch(searchDTO));
    }

}
